package com.jbm.jbmsupplier.activity;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.widget.TextView;

import com.jbm.jbmsupplier.R;
import com.jbm.jbmsupplier.adapter.FragmentAdapter;
import com.jbm.jbmsupplier.frement.PledFrament;
import com.jbm.jbmsupplier.utlis.ExitActivity;

import java.util.ArrayList;

import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.OnClick;

/**
 * Created by 家帮忙 on 2017/4/11.
 */

public class PledgeList extends AllActivityApp /*implements PledgeViews */ {


    @InjectView(R.id.tetitle)
    TextView tetitle;
    @InjectView(R.id.teleft)
    TextView teleft;
    @InjectView(R.id.tabs)
    TabLayout tabs;
    @InjectView(R.id.viewpagerple)
    ViewPager viewpagerple;
    @Override
    public int setContentView() {
        return R.layout.pledgrlistframent;
    }

    @Override
    public void initIalizeView() {
        ExitActivity.getInstance().addActivity(this);
        ButterKnife.inject(this);
        tetitle.setText("钱包");
        setLoadTitle();
    }
        public void setLoadTitle(){
            ArrayList<String> arrtitle=new ArrayList<>();
            final ArrayList<Fragment> arrfrag=new ArrayList<>();
            arrtitle.add("钱包");
            arrtitle.add("月结列表");
            for (int i = 0; i <arrtitle.size() ; i++) {
                tabs.addTab(tabs.newTab().setText(arrtitle.get(i).toString()));
            }
            for (int i = 0; i <arrtitle.size() ; i++) {
                arrfrag.add(new PledFrament());
            }
            FragmentAdapter mFragmentAdapteradapter = new FragmentAdapter(getSupportFragmentManager(), arrfrag, arrtitle);
            viewpagerple.setAdapter(mFragmentAdapteradapter);
            tabs.setupWithViewPager(viewpagerple);
            tabs.setTabsFromPagerAdapter(mFragmentAdapteradapter);
            viewpagerple.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
               @Override
               public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

               }

               @Override
               public void onPageSelected(int position) {
                   String stati="";
                         if (position==0){

                         }else  if (position==1){

                         }
                   ( (PledFrament)arrfrag.get(position)).setDatePleaMoeny(position,stati);



               }

               @Override
               public void onPageScrollStateChanged(int state) {

               }
           });


            }


    public interface DatePleaMoeny{//请求金额

        void setDatePleaMoeny(int i, String sta);
    }





    @OnClick(R.id.teleft)
    public void onViewClicked() {
        finish();
    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.inject(this);
    }
}
